package com.hnucm.app4;

import androidx.annotation.MainThread;
import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        EditText editText=findViewById(R.id.editTextTextPersonName);
        EditText editPasswd=findViewById(R.id.editTextTextPersonName2);
        Button btn=findViewById(R.id.button);

        //在activity文件下获取图片
        ImageView imgView = findViewById(R.id.imgView1);
        imgView.setImageDrawable(getResources().getDrawable(R.drawable.abc_vector_test));

        Student student=new Student();

        btn.setOnClickListener(
                (button)->{
                    student.name =editText.getText().toString();
                    student.pwd =editPasswd.getText().toString();
//                    if(userPasswd.equals("123456")){
//                        Log.i("scuess1",userName);
//                        Log.i("scuess2",userPasswd);
//
//                        Log.i("scuess","登录成功");
                        Toast.makeText(MainActivity.this, "登录成功", Toast.LENGTH_SHORT).show();

                        Intent intent=new Intent(MainActivity.this, MainActivity2.class);
                        //页面间的值传递
                        intent.putExtra("stu",student);
                        startActivity(intent);
//                    }else{
//                        Log.i("default",userName);
//                        Log.i("default1",userPasswd);
//                        Log.i("default2","登录失败");
//                        Toast.makeText(MainActivity.this, "登录失败", Toast.LENGTH_SHORT).show();
//
//                    }
                }

        );

    }
}